<?php
define('NOCITYCODE', TRUE);
require '../member/include/common.inc.php';
include './include/global.func.php';
$lang = include './include/lang.inc.php';
$cityparam = "&amp;acode=$acode";
$cityparamindex = "?acode=$acode";

$title = iconv('gbk', 'utf-8', '用户注册');
wmlHeader($title);



if($dosubmit){
    
    $memberinfo['username'] = $username;
    $memberinfo['password'] = $password;
    $memberinfo['email'] = $useremail;
    $memberinfo['areacode'] = $citycode;//新用户的地区编号为当前地区站
    $memberinfo['modelid'] = 10;//用户模型ID
    $memberinfo['groupid'] = 1;//用户组ID

    if(strlen($password)<6) err('密码长度至少6位！');

    if($DC['uc']){
        extract($memberinfo);
	    $uid = uc_call("uc_user_register", array($username, $password, $useremail));
        	if($uid <= 0)
        	{
        		if($uid == -1)
        		{
        			err('用户名不合法');
        		}
        		elseif($uid == -2)
        		{
        			err('包含要允许注册的词语');
        		}
        		elseif($uid == -3)
        		{
        			err('用户名已经存在');
        		}
        		elseif($uid == -4)
        		{
        			err('Email 格式有误');
        		}
        		elseif($uid == -5)
        		{
        			err('Email 不允许注册');
        		}
        		elseif($uid == -6)
        		{
        			err('该 Email 已经被注册');
        		}
        		else
        		{
        			err('未定义');
        		}

        	}
        	$userid = '';
        	$r = $member->get_by_touserid($uid);//modify by skyz
        	if(!$r)
        	{
        		require_once MOD_ROOT.'api/member_api.class.php';
        		$member_api = new member_api();
        		$memberinfo['touserid'] = $uid;//modify by skyz
        		$userid = $member_api->add($memberinfo);
        	}
    }
    if(!$userid)
    {
        $userid = $member->register($memberinfo);
    }
    if($userid){
        echo gb2u('注册成功！');
        echo '<a href="login.php'.$cityparamindex.'">';
        echo gb2u('点击这里登陆...');
        echo '</a>';
    }

/**
    if($member->msg()){
        err($member->msg());
    }else{
        echo gb2u('注册成功！');
        echo '<a href="login.php'.$cityparamindex.'">';
        echo gb2u('点击这里登陆...');
        echo '</a>';
    }
/**/

}else{
    $html .= '注册:<br />
    Email<br />
    <input name="useremail" value="" emptyok="true"/><br />
    昵称:<br />
    <input name="username" value="" emptyok="true"/><br />
    密码:(6-12个字符)<br />
    <input name="password" value="" emptyok="true" type="password"/><br />
    <anchor title="提交注册">提交注册
    	<go href="reg.php" method="post">
    		<postfield name="username" value="$(username)"/>
    		<postfield name="useremail" value="$(useremail)" />
    		<postfield name="password" value="$(password)" />
    		<postfield name="acode" value="'.$acode.'" />
    		<postfield name="dosubmit" value="1"></postfield>
    	</go>
    </anchor>';
}


$html .= "<br/><br/>";
$html .= '<anchor title="back">返回<prev/></anchor> <br/>';

$html =  iconv('gbk', 'utf-8', $html);
echo str_replace('<br/>', "<br/>\n", $html);

wmlFooter();
?>